import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Condition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import org.springframework.util.MultiValueMap;

import java.util.List;

public class CityCondition implements Condition {

    @Override
    public boolean matches(ConditionContext conditionContext, AnnotatedTypeMetadata annotatedTypeMetadata) {
        MultiValueMap<String, Object> multiValueMap = annotatedTypeMetadata.getAllAnnotationAttributes(Bean.class.getName());
        List<Object> objectList = multiValueMap.get("name");
        for (Object object : objectList) {
            String[] strings = (String[]) object;
            if ("city".equals(strings[0])) {
                return true;
            }
        }
        return false;
    }
}
